package com.example.NeteaseCloudMusicApi.ui.adapter;

import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.NeteaseCloudMusicApi.R;
import com.example.NeteaseCloudMusicApi.entity.Found;
import com.example.NeteaseCloudMusicApi.entity.My;
import com.example.NeteaseCloudMusicApi.entity.News;
import com.example.NeteaseCloudMusicApi.ui.activity.MainActivity;

import java.util.List;

import static androidx.constraintlayout.motion.utils.Oscillator.TAG;

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {

    private List<My> mMy;

    public static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView image;
        TextView name;
        public ViewHolder (View view) {
            super(view);
            image = view.findViewById(R.id.my_recycler_image);
            name = view.findViewById(R.id.my_recycle_information);
        }
    }

    public MyAdapter(List<My> my){
        mMy = my;
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_recycler,parent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position){

        My my = mMy.get(position);
        holder.image.setImageResource(my.getImageId());
        holder.name.setText(my.getName());


    }

    @Override
    public int getItemCount(){
        return mMy.size();
    }
}
